package com.zp.qualitypractice.list.demo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;

import com.zp.qualitypractice.R;
import com.zp.qualitypractice.list.OnPullLoadListener;
import com.zp.qualitypractice.list.RefreshLayout;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by izp on 2017/4/19.
 */

public class NestRefreshActivity extends AppCompatActivity implements OnPullLoadListener{
    private RefreshLayout recycler;
    private View header;
    private View footer;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_refresh_list);
        inital();
    }

    private void inital() {
        recycler = (RefreshLayout) findViewById(R.id.refreshLayout);
        List<String> list = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            list.add(i + 1 + "");
        }
        header= LayoutInflater.from(this).inflate(R.layout.item_header,null);
        footer= LayoutInflater.from(this).inflate(R.layout.item_footer,null);
        recycler.addHeaderView(header,100);
        recycler.addFooterView(footer,100);
        NumberAdapter adapter = new NumberAdapter(this, list);
        recycler.setRefreshRecyclerView(new LinearLayoutManager(this), adapter,null);
        recycler.addOnTouchUpListener(this);
    }

    @Override
    public void onRefreshing() {

    }

    @Override
    public void onLoading() {

    }
}
